Skip to content

[Parse] Allow whitespaces before period in superclass-expression #5423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,10 @@ ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
/*Implicit=*/false))
: cast<Expr>(new (Context) ErrorExpr(superLoc));

if (Tok.is(tok::period)) {
if (Tok.isAny(tok::period, tok::period_prefix)) {
// 'super.' must be followed by a member or initializer ref.

SourceLoc dotLoc = consumeToken(tok::period);
SourceLoc dotLoc = consumeToken();

if (Tok.is(tok::code_complete)) {
if (CodeCompletion) {
Expand Down
7 changes: 7 additions & 0 deletions test/Parse/super.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class D : B {
let _: () -> D = self.init // expected-error {{partial application of 'self.init' initializer delegation is not allowed}}
}

init(z: Int) {
super
.init(x: z)
}

func super_calls() {
super.foo // expected-error {{expression resolves to an unused l-value}}
super.foo.bar // expected-error {{value of type 'Int' has no member 'bar'}}
Expand All @@ -35,6 +40,8 @@ class D : B {
super.init() // expected-error{{'super.init' cannot be called outside of an initializer}}
super.init(0) // expected-error{{'super.init' cannot be called outside of an initializer}}
super[0] // expected-error {{expression resolves to an unused l-value}}
super
.bar()
}

func bad_super_1() {
Expand Down