From bac9ff47de23381f6b6a0cf1a46a500eaf237783 Mon Sep 17 00:00:00 2001 From: John Vasileff Date: Thu, 23 Jun 2016 09:16:05 -0400 Subject: [PATCH] don't assume a token in uIdentifierToCeylon This is for consistency with changes necessary for #114. --- source/ceylon/ast/redhat/Identifier.ceylon | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/ceylon/ast/redhat/Identifier.ceylon b/source/ceylon/ast/redhat/Identifier.ceylon index df282266..37f1bc99 100644 --- a/source/ceylon/ast/redhat/Identifier.ceylon +++ b/source/ceylon/ast/redhat/Identifier.ceylon @@ -68,11 +68,16 @@ shared LIdentifier lIdentifierToCeylon(JIdentifier identifier, Anything(JNode,No "Converts a RedHat AST [[Identifier|JIdentifier]] to a `ceylon.ast` [[UIdentifier]]." throws (`class AssertionError`, "If the token type is not `UIDENTIFIER`.") shared UIdentifier uIdentifierToCeylon(JIdentifier identifier, Anything(JNode,Node) update = noop) { - "Need CommonToken to get length of token (!= text’s length for \\iCONSTANT)" - assert (is CommonToken token = identifier.mainToken); - "Must be UIDENTIFIER token" - assert (token.type == uidentifier); - value result = UIdentifier(identifier.text, isPrefixed(token)); + "Need CommonToken to get length of token (!= text’s length for \\iCONSTANT). + For synthetic nodes produced by the typechecker during desugaring, a token + may not exist." + assert (is CommonToken? token = identifier.mainToken); + if (exists token) { + "Must be UIDENTIFIER token" + assert (token.type == uidentifier); + } + value prefixed = if (exists token) then isPrefixed(token) else false; + value result = UIdentifier(identifier.text, prefixed); update(identifier, result); return result; }