2014-07-22 7 views
9

क्यों जब मैं सामान्य वर्ग के लिए enum जोड़ने मैं कोई त्रुटि मिलती है:जब मैं सामान्य वर्ग में enum जोड़ता हूं तो एक्सकोड बिल्ड त्रुटि?

class TestClass<T>{ 
    enum TestEnum { 
     case test 
    } 
} 

त्रुटि:

1. While type-checking 'ExampleTest' at /Users/xxx/xxx/xx/xx/ExampleTest.swift:11:1 
<unknown>:0: error: unable to execute command: Segmentation fault: 11 
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation) 
Command /Applications/Xcode6-Beta3 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254 

लेकिन जब मैं यह कर मैं एक त्रुटि नहीं मिलता:

class TestClass{ 
    enum TestEnum { 
     case test 
    } 
} 

या यह:

class TestClass<T>{ 
} 
+2

आपके पहले दो उदाहरण बिल्कुल समान हैं - क्या यह संभव है कि आपने दो बार एक ही स्निपेट पोस्ट किया हो? – weltraumpirat

+0

जेनेरिक क्लास और नेस्टेड एनम के संयोजन के साथ कंपाइलर बग। [एक बग रिपोर्ट फ़ाइल करें] (https://bugreport.apple.com/) और अब कामकाज के रूप में गणना के लिए गणना करें। –

+0

@weltraumpirat धन्यवाद, उदाहरण को सही किया। – Jimmy

उत्तर

20

आप किसी सामान्य प्रकार के अंदर किसी भी प्रकार का घोंसला नहीं बना सकते हैं और इसके विपरीत।

और

class Outer { 
    class Inner<T> { } 
} 

और यहां तक ​​कि

class Outer<T> { 
    class Inner<T> { } 
} 

एप्पल लोगों explained कारण: दूसरे शब्दों में, आप कक्षाएं, structs, और enums के लिए इस तरह की बातें नहीं कर सकते हैं प्रतिबंध के लिए:

It's an implementation limitation. We'll remove the restriction once our compiler and runtime are able to correctly handle types nested in generic contexts.

पीएस क्षमा करें कि मैं उत्तर बहुत देर से पोस्ट करता हूं लेकिन समस्या अभी भी वहां है (एक्सकोड 6.2)।

वैसे भी बहुत ही question था।

+3

स्विफ्ट 3.1 और एक्सकोड 8.3.2 अब इसका समर्थन करते हैं –

संबंधित मुद्दे

 संबंधित मुद्दे