Skip to content

Commit 678f2b7

Browse files
committed
Fix #1605: don't inline methods that have errors
1 parent 0fdd4e3 commit 678f2b7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 5 additions & 3 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
@@ -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)