Skip to content

Commit 1d32763

Browse files
committed
add test
1 parent ef38642 commit 1d32763

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ class ValueClassParameterMayNotBeCallByName(valueClass: Symbol, param: Symbol)(u
18151815

18161816
class ValueClassCannotExtendAliasOfAnyVal(valueClass: Symbol, alias: Symbol)(using Context)
18171817
extends SyntaxMsg(ValueClassCannotExtendAliasOfAnyValID) {
1818-
def msg(using Context) = i"""Value class cannot extend from alias $alias of ${hl("AnyVal")} """
1818+
def msg(using Context) = i"""Value class cannot extend from an alias $alias of ${hl("AnyVal")} """
18191819
def explain(using Context) = ""
18201820
}
18211821

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ object Checking {
762762
if (clazz.isDerivedValueClass && !clazz.isEnumAnonymClass) {
763763
val implTree @ Template(_, _, _, _) = cdef.rhs: @unchecked
764764
val parent = implTree.parents.head
765-
val isExtendingAliasOfAnyVal = parent.tpe.nn.dealias =:= defn.AnyValType && !(parent.tpe.nn =:= defn.AnyValType)
765+
val isExtendingAliasOfAnyVal = parent.tpe.nn.dealias =:= defn.AnyValType && parent.symbol.isAliasType
766766

767767
if (clazz.is(Trait))
768768
report.error(CannotExtendAnyVal(clazz), clazz.srcPos)

tests/neg/i21918.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type AliasToAnyVal = AnyVal
2+
class Foo(a: Int) extends AliasToAnyVal // error

0 commit comments

Comments
 (0)