Skip to content

Commit 98c6a03

Browse files
committed
Fix #1605: don't inline methods that have errors
1 parent 5d59024 commit 98c6a03

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ object Inliner {
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
@@ -191,7 +191,9 @@ object Inliner {
191191
sym.updateAnnotation(LazyBodyAnnotation { _ =>
192192
implicit val ctx: Context = inlineCtx
193193
val tree1 = treeExpr(ctx)
194-
makeInlineable(tree1)
194+
if (tree1.hasType && !tree1.tpe.isError)
195+
makeInlineable(tree1)
196+
else tree1
195197
})
196198
}
197199
}

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 // error
5+
}

0 commit comments

Comments
 (0)