Skip to content

Commit d2a0b3c

Browse files
oderskyKordyjan
authored andcommitted
Make constructors effectively final
This is mainly a cleanup.
1 parent 8e9b718 commit d2a0b3c

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ object SymDenotations {
11961196
isOneOf(EffectivelyFinalFlags)
11971197
|| is(Inline, butNot = Deferred)
11981198
|| is(JavaDefinedVal, butNot = Method)
1199+
|| isConstructor
11991200
|| !owner.isExtensibleClass
12001201

12011202
/** A class is effectively sealed if has the `final` or `sealed` modifier, or it

compiler/src/dotty/tools/dotc/transform/init/Util.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ object Util:
7575
case _ =>
7676
None
7777

78-
def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show) {
79-
if (sym.isEffectivelyFinal || sym.isConstructor) sym
78+
def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show):
79+
if sym.isEffectivelyFinal then sym
8080
else sym.matchingMember(cls.appliedRef)
81-
}
82-
8381

8482
extension (sym: Symbol)
8583
def hasSource(using Context): Boolean = !sym.defTree.isEmpty

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ class RefChecks extends MiniPhase { thisPhase =>
16891689
// if (settings.warnNullaryUnit)
16901690
// checkNullaryMethodReturnType(sym)
16911691
// if (settings.warnInaccessible) {
1692-
// if (!sym.isConstructor && !sym.isEffectivelyFinal && !sym.isSynthetic)
1692+
// if (!sym.isEffectivelyFinal && !sym.isSynthetic)
16931693
// checkAccessibilityOfReferencedTypes(tree)
16941694
// }
16951695
// tree match {

0 commit comments

Comments
 (0)