Skip to content

Commit f796d5a

Browse files
committed
Don't interpolate or simplify overloaded references
Simplifying an overloaded reference risks changing the prefix, which will lead into trouble using the new overloading scheme (because the only info is in the denotation, which will be thrown away when the prefix is changed). Also, both interpolating undetermined variables and simplifying are likely to be inefficient on overloaded types because they tend to be large. Delaying these operations means we only have to perform them on alternatives that might plausibly match the expected type.
1 parent 3da22fd commit f796d5a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,12 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
18671867

18681868
def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = /*>|>*/ track("adapt") /*<|<*/ {
18691869
/*>|>*/ trace(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ {
1870-
if (tree.isDef) interpolateUndetVars(tree, tree.symbol)
1871-
else if (!tree.tpe.widen.isInstanceOf[LambdaType]) interpolateUndetVars(tree, NoSymbol)
1872-
tree.overwriteType(tree.tpe.simplified)
1870+
if (!tree.denot.isOverloaded) {
1871+
// for overloaded trees: resolve overloading before simplifying
1872+
if (tree.isDef) interpolateUndetVars(tree, tree.symbol)
1873+
else if (!tree.tpe.widen.isInstanceOf[LambdaType]) interpolateUndetVars(tree, NoSymbol)
1874+
tree.overwriteType(tree.tpe.simplified)
1875+
}
18731876
adaptInterpolated(tree, pt)
18741877
}
18751878
}

0 commit comments

Comments
 (0)