Skip to content

Commit 9fff5e9

Browse files
committed
Fix #1605: don't methods that have errors
1 parent 8bfaada commit 9fff5e9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ object Inliner {
140140

141141
override def transform(tree: Tree)(implicit ctx: Context): Tree = super.transform {
142142
tree match {
143-
case _: Apply | _: TypeApply | _: RefTree if needsAccessor(tree.symbol) =>
143+
case _: Apply | _: TypeApply | _: RefTree if tree.hasType && needsAccessor(tree.symbol) =>
144144
if (tree.isTerm) {
145145
val (methPart, targs, argss) = decomposeCall(tree)
146146
addAccessor(tree, methPart, targs, argss,
147147
accessedType = methPart.tpe.widen,
148148
rhs = (qual, tps, argss) => qual.appliedToTypes(tps).appliedToArgss(argss))
149-
} else {
149+
} else {
150150
// TODO: Handle references to non-public types.
151151
// This is quite tricky, as such types can appear anywhere, including as parts
152152
// of types of other things. For the moment we do nothing and complain
@@ -168,8 +168,10 @@ object Inliner {
168168
}
169169
}
170170

171-
val tree1 = addAccessors.transform(tree)
172-
flatTree(tree1 :: addAccessors.accessors.toList)
171+
if (tree.hasType && !tree.tpe.isError) {
172+
val tree1 = addAccessors.transform(tree)
173+
flatTree(tree1 :: addAccessors.accessors.toList)
174+
} else tree
173175
}
174176

175177
/** Register inline info for given inline method `sym`.

tests/neg/i1605.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
def foo = inlineMe
3+
4+
inline def inlineMe = 1 + x
5+
}

0 commit comments

Comments
 (0)