Skip to content

Commit 1c42de7

Browse files
committed
Fix erroneous isInstanceOf test in compiler
1 parent effb9d1 commit 1c42de7

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ enum ErrorMessageID extends java.lang.Enum[ErrorMessageID]:
131131
DoubleDefinitionID,
132132
MatchCaseOnlyNullWarningID,
133133
ImportRenamedTwiceID,
134-
TypeTestAlwaysSucceedsID,
134+
TypeTestAlwaysDivergesID,
135135
TermMemberNeedsNeedsResultTypeForImplicitSearchID,
136136
ClassCannotExtendEnumID,
137137
ValueClassParameterMayNotBeCallByNameID,

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,13 +2177,9 @@ import transform.SymUtils._
21772177
def explain = ""
21782178
}
21792179

2180-
class TypeTestAlwaysSucceeds(scrutTp: Type, testTp: Type)(using Context) extends SyntaxMsg(TypeTestAlwaysSucceedsID) {
2181-
def msg = {
2182-
val addendum =
2183-
if (scrutTp != testTp) s" is a subtype of ${testTp.show}"
2184-
else " is the same as the tested type"
2185-
s"The highlighted type test will always succeed since the scrutinee type ${scrutTp.show}" + addendum
2186-
}
2180+
class TypeTestAlwaysDiverges(scrutTp: Type, testTp: Type)(using Context) extends SyntaxMsg(TypeTestAlwaysDivergesID) {
2181+
def msg =
2182+
s"This type test will never return a result since the scrutinee type ${scrutTp.show} does not contain any value."
21872183
def explain = ""
21882184
}
21892185

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class TreeChecker extends Phase with SymTransformer {
418418
}
419419

420420
override def typedSuper(tree: untpd.Super, pt: Type)(using Context): Tree =
421-
assert(tree.qual.tpe.isInstanceOf[ThisType], i"expect prefix of Super to be This, actual = ${tree.qual}")
421+
assert(tree.qual.typeOpt.isInstanceOf[ThisType], i"expect prefix of Super to be This, actual = ${tree.qual}")
422422
super.typedSuper(tree, pt)
423423

424424
override def typedTyped(tree: untpd.Typed, pt: Type)(using Context): Tree =

0 commit comments

Comments
 (0)