From 551f09fddf8ec8a61eb6c4af890ef97bf77dc35d Mon Sep 17 00:00:00 2001 From: gavinking Date: Sat, 2 Sep 2017 20:15:55 +0200 Subject: [PATCH] disallow 'default late' because it has unclear semantics #6455 --- typechecker/en/modules/declarations.xml | 3 ++- .../compiler/typechecker/analyzer/DeclarationVisitor.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/typechecker/en/modules/declarations.xml b/typechecker/en/modules/declarations.xml index b5996fb83fd..d38e2ac0bfc 100644 --- a/typechecker/en/modules/declarations.xml +++ b/typechecker/en/modules/declarations.xml @@ -2662,7 +2662,8 @@ case (hexadecimal) { A reference annotated late may not be initialized or assigned a value by the class initializer. A parameter may not be annotated late. A reference not belonging to a class may not be annotated - late. + late. A reference annotated formal or + default may not be annotated late. If a class declares or inherits a variable reference, it must (directly or indirectly) extend the class Basic defined in diff --git a/typechecker/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java b/typechecker/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java index bfe54b66b1c..3a045454f18 100644 --- a/typechecker/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java +++ b/typechecker/src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java @@ -1450,6 +1450,9 @@ public void visit(Tree.AttributeDeclaration that) { if (v.isFormal()) { that.addError("formal attribute may not be annotated 'late'"); } + else if (v.isDefault()) { + that.addError("default attribute may not be annotated 'late'"); + } else if (!v.isClassOrInterfaceMember() && !v.isToplevel()) { that.addError("block-local value may not be annotated 'late'");