Skip to content

Commit 7c56358

Browse files
committed
Do ignore expected prototypes of New
It turns out an sjsJUnitTest fails otherwise, since that one _does_ insert an implicit conversion after a `new`. This is all goes to show that what we do to deal with implicit conversions is completely crazy. It's a black art when to propagate exected types. There's often no better or worse. Almost any change we do can heal some code and break some other code. I believe the only way to get our of this swamp is to get rid of unrestricted implicit conversions.
1 parent b009f42 commit 7c56358

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ trait Applications extends Compatibility {
893893

894894
def realApply(using Context): Tree = {
895895
val resultProto = tree.fun match
896-
case Select(New(_), _) => pt
897-
// Don't ignore expected types of `new` expressions. If we have a `new C()`
896+
case Select(New(_), _) if pt.isInstanceOf[ValueType] => pt
897+
// Don't ignore expected value types of `new` expressions. If we have a `new C()`
898898
// with expected type `C[T]` we want to use the type to instantiate `C`
899899
// immediately. This is necessary since `C` might _also_ have using clauses
900900
// that we want to instantiate with the best available type. See i15664.scala.

0 commit comments

Comments
 (0)