diff --git a/modules/standard/Sort.chpl b/modules/standard/Sort.chpl index e9899aa6e77a..a7765354e618 100644 --- a/modules/standard/Sort.chpl +++ b/modules/standard/Sort.chpl @@ -451,15 +451,6 @@ proc chpl_check_comparator(comparator, } // Check for valid comparator methods else if canResolveMethod(comparator, "key", data) { - if doDeprecationCheck && !comparatorImplementsKey(comparator) { - param atType = if isRecord(comparator) then "record" else "class"; - param fixString = "'" + atType + " " + - comparator.type:string + ": keyComparator'"; - compilerWarning(errorDepth=errorDepth, - "Defining a comparator with a 'key' method without " + - "implementing the keyComparator interface is deprecated. " + - "Please implement the keyComparator interface (i.e. " + fixString + ")."); - } // Check return type of key const keydata = comparator.key(data); type keytype = keydata.type; @@ -484,6 +475,15 @@ proc chpl_check_comparator(comparator, comparator.type:string, " contains both a key method and a keyPart method"); } + if doDeprecationCheck && !comparatorImplementsKey(comparator) { + param atType = if isRecord(comparator) then "record" else "class"; + param fixString = "'" + atType + " " + + comparator.type:string + ": keyComparator'"; + compilerWarning(errorDepth=errorDepth, + "Defining a comparator with a 'key' method without " + + "implementing the keyComparator interface is deprecated. " + + "Please implement the keyComparator interface (i.e. " + fixString + ")."); + } } else if canResolveMethod(comparator, "compare", data, data) { if doDeprecationCheck { diff --git a/test/library/standard/Sort/errors/errors-comparator.chpl b/test/library/standard/Sort/errors/errors-comparator.chpl index 2482122ed864..276c98e149bf 100644 --- a/test/library/standard/Sort/errors/errors-comparator.chpl +++ b/test/library/standard/Sort/errors/errors-comparator.chpl @@ -51,7 +51,6 @@ proc keyPartArgs.keyPart(a) { return a; } -// this should still get a deprecation warning // Both key and compare record keyAndCompare { } proc keyAndCompare.key(a) { @@ -61,7 +60,6 @@ proc keyAndCompare.compare(a, b) { return 0; } -// this should still get a deprecation warning // Both key and keyPart record keyAndKeyPart { } proc keyAndKeyPart.key(a) { diff --git a/test/library/standard/Sort/errors/errors-comparator.keyandcompare.good b/test/library/standard/Sort/errors/errors-comparator.keyandcompare.good index 0b17b9445436..c2219c0f3402 100644 --- a/test/library/standard/Sort/errors/errors-comparator.keyandcompare.good +++ b/test/library/standard/Sort/errors/errors-comparator.keyandcompare.good @@ -1,3 +1,2 @@ errors-comparator.chpl:9: In function 'main': -errors-comparator.chpl:17: warning: Defining a comparator with a 'key' method without implementing the keyComparator interface is deprecated. Please implement the keyComparator interface (i.e. 'record keyAndCompare: keyComparator'). errors-comparator.chpl:17: error: keyAndCompare contains both a key method and a compare method diff --git a/test/library/standard/Sort/errors/errors-comparator.keyandkeypart.good b/test/library/standard/Sort/errors/errors-comparator.keyandkeypart.good index b19108916832..a401f5df7f26 100644 --- a/test/library/standard/Sort/errors/errors-comparator.keyandkeypart.good +++ b/test/library/standard/Sort/errors/errors-comparator.keyandkeypart.good @@ -1,3 +1,2 @@ errors-comparator.chpl:9: In function 'main': -errors-comparator.chpl:17: warning: Defining a comparator with a 'key' method without implementing the keyComparator interface is deprecated. Please implement the keyComparator interface (i.e. 'record keyAndKeyPart: keyComparator'). errors-comparator.chpl:17: error: keyAndKeyPart contains both a key method and a keyPart method