Files
swift-mirror/test/expr/delayed-ident/enum.swift
Doug Gregor 19759529db Allow delayed identifier expressions (.foo) with static variables and methods.
This allows expressions such as ".foo" and ".foo(1)" to refer to
static variables and static methods, respectively, as well as enum
cases. 

To get here, rework the parsing of delayed identifier expressions a
bit, so that the argument itself is part of the delayed argument
expression rather than a separate call expression. This simplifies
both the handling of patterns of this form and the type checker, which
can now user simpler constraints.

If we really want to support (.foo)(1), we can make that work, but it
seems unnecessary and perhaps confusing.


Swift SVN r10626
2013-11-21 06:24:06 +00:00

25 lines
433 B
Swift

// RUN: %swift -parse %s -verify
// Simple enumeration type
enum E1 {
case First
case Second(x: Int)
case Third(x: Int, d: Double)
}
var e1: E1 = .First
e1 = .Second(5)
e1 = .Third(5, 3.14159)
// Generic enumeration type
enum E2<T> {
case First
case Second(x: T)
}
var e2a: E2<Int> = .First
e2a = .Second(5)
var e2b: E2 = .Second(5)
e2b = .First
var e2c: E2 = .First // expected-error{{expression does not type-check}}