Merge pull request #21396 from slavapestov/enum-curry-thunk-regression-5.0
SILGen: Fix partial application of enum case with one-element labeled tuple [5.0]
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6ef61d..0235c19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -912,8 +912,9 @@
# https://bugs.swift.org/browse/SR-5975
add_subdirectory(stdlib)
+add_subdirectory(include)
+
if(SWIFT_INCLUDE_TOOLS)
- add_subdirectory(include)
add_subdirectory(lib)
# Always include this after including stdlib/!
diff --git a/cmake/modules/StandaloneOverlay.cmake b/cmake/modules/StandaloneOverlay.cmake
index 54b7b39..98f55ef 100644
--- a/cmake/modules/StandaloneOverlay.cmake
+++ b/cmake/modules/StandaloneOverlay.cmake
@@ -58,6 +58,10 @@
precondition(SWIFT_HOST_VARIANT_SDK)
precondition(TOOLCHAIN_DIR)
+# Some overlays include the runtime's headers,
+# and some of those headers are generated at build time.
+add_subdirectory("${SWIFT_SOURCE_DIR}/include" "swift/include")
+
# Without this line, installing components is broken. This needs refactoring.
swift_configure_components()
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 569c1db..e238c58 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -3498,6 +3498,8 @@
"cannot create a single-element tuple with an element label", ())
ERROR(tuple_ellipsis,none,
"cannot create a variadic tuple", ())
+ERROR(enum_element_ellipsis,none,
+ "variadic enum cases are not supported", ())
WARNING(implicitly_unwrapped_optional_in_illegal_position_interpreted_as_optional,none,
"using '!' is not allowed here; treating this as '?' instead", ())
diff --git a/include/swift/CMakeLists.txt b/include/swift/CMakeLists.txt
index 6f207d9..2db8f14 100644
--- a/include/swift/CMakeLists.txt
+++ b/include/swift/CMakeLists.txt
@@ -1,6 +1,14 @@
-configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
- ESCAPE_QUOTES @ONLY)
+if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY OR SWIFT_BUILD_STANDALONE_OVERLAY)
+ add_subdirectory(Runtime)
+endif()
-add_subdirectory(Option)
-add_subdirectory(SwiftRemoteMirror)
-add_subdirectory(Syntax)
+if(SWIFT_BUILD_REMOTE_MIRROR)
+ add_subdirectory(SwiftRemoteMirror)
+endif()
+
+if(SWIFT_INCLUDE_TOOLS)
+ configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
+ ESCAPE_QUOTES @ONLY)
+ add_subdirectory(Option)
+ add_subdirectory(Syntax)
+endif()
diff --git a/include/swift/Runtime/CMakeLists.txt b/include/swift/Runtime/CMakeLists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/swift/Runtime/CMakeLists.txt
diff --git a/lib/Sema/TypeCheckPattern.cpp b/lib/Sema/TypeCheckPattern.cpp
index cfddd4d..ea0c11d 100644
--- a/lib/Sema/TypeCheckPattern.cpp
+++ b/lib/Sema/TypeCheckPattern.cpp
@@ -723,6 +723,7 @@
if (auto ty = decl->getTypeLoc().getType())
return ty->hasError();
+ auto origContext = options.getContext();
options.setContext(None);
// If the element is a variadic parameter, resolve the parameter type as if
@@ -764,6 +765,12 @@
hadError = true;
}
TL.setType(Ty);
+
+ // Disallow variadic parameters in enum elements.
+ if (!hadError && origContext == TypeResolverContext::EnumElementDecl) {
+ TC.diagnose(decl->getStartLoc(), diag::enum_element_ellipsis);
+ hadError = true;
+ }
}
if (hadError)
diff --git a/test/decl/enum/enumtest.swift b/test/decl/enum/enumtest.swift
index ae86aed..553e42f 100644
--- a/test/decl/enum/enumtest.swift
+++ b/test/decl/enum/enumtest.swift
@@ -326,3 +326,10 @@
case baz((inout T) -> ()) // ok
case quux((inout T, inout T) -> ()) // ok
}
+
+// In the long term, these should be legal, but we don't support them right
+// now and we shouldn't pretend to.
+// rdar://46684504
+enum HasVariadic {
+ case variadic(x: Int...) // expected-error {{variadic enum cases are not supported}}
+}